#include "base/eventloop.h"
#include "base/thread.h"
#include <sys/syscall.h>
#include <unistd.h>
#include "base/logthread.h"
namespace net_tools
{
  Logthread::Logthread(std::string app_name, FILE *file_stream)
      : log_(std::move(app_name)),
        logthread_(nullptr, 16, "Log thread"),
        eventloop_(logthread_.Get_eventloop_())
  {
    log_.Init(eventloop_, file_stream);
    timeval now_, sec_;
    gettimeofday(&now_, NULL);
    sec_.tv_sec = _C::SET_LOG_FLUSH_SEC;
    sec_.tv_usec = _C::SET_LOG_FLUSH_USEC;
    eventloop_->Run_every(log_.flush_, now_, sec_, _C::TIMEJOB_FOREVER, "Log flush");
  };
  Logthread::~Logthread(){};

} // namespace net_tools